<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
      $this->display();
    }

    public function action(){
      if(I('post.username')=="")$this->error("用户名不能为空");
      if($user=M('user')->where('username="'.I('post.username').'" and password="'.md5(md5(I('post.password'))).'"')->select()[0]){
        session('id',$user['id']);
        session('username',$user['username']);
        $this->redirect('Index/index');
      }
      else
        $this->error("用户名或密码错误!");
    }
}
